<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="../static/js/jquery-1.8.2.min.js"></script>
</head>
<body>
<div class="container">
    <div align="center">
        <div style="font-size: 30px"><span>来帮你的好友</span><span id="userName" style="color: red"></span>砍一刀吧</div>
        <div><img src="" alt="" id="img" width="300px" height="300px"></div>
        <div style="font-size: 30px"><span id="goodsName"></span></div>
        <div><input type="button" class="btn btn-primary btn-lg" value="帮他砍一刀" id="kan"></div>
    </div>
</div>
</body>
<script>
    $.post(
        "/record/findOrder",
        {"userId":[[${param.userId}]],"orderId":[[${param.orderId}]]},
        function (a) {
            if (a==0){
                location = "/record/goNull";
            }
        }
    )

    $.post(
        "/user/echo",
        {"userId":[[${param.userId}]]},
        function (a){
            $("#userName").html(a.userName);
        }
    )
    $.post(
        "/order/echo2",
        {"orderId":[[${param.orderId}]]},
        function (a) {
            $("#img").attr("src",a.goodsImg);
            $("#goodsName").html(a.goodsName);
        }
    )
    $("#kan").click(function () {
        $.post(
            "/order/bargain",
            {"orderId":[[${param.orderId}]],"userId":[[${param.userId}]]},
            function (a) {
                if (a==0){
                    alert("不可以对自己进行砍价");
                }else if (a==1){
                    alert("帮助好友砍价成功");
                }else if (a==2){
                    alert("您已经对该商品砍过价了");
                }else {
                    alert("失败");
                }
            }
        )
    })
</script>
</html>
